package cn.liutao.bill.api;

import cn.hutool.core.util.StrUtil;
import cn.liutao.bill.vo.PriceRangeVo;
import cn.liutao.common.utils.AuthUtils;
import cn.liutao.common.utils.ServletUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author liutao
 * @Description 价格区间排行
 * @date 2023/11/5
 */
@WebServlet("/bill/priceRangeRank")
public class PriceRangeRank extends BillServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        AuthUtils.isAdmin();
        String parameter = req.getParameter("orderBy");
        Integer orderBy = 0;
        if (StrUtil.isNotEmpty(parameter)) {
            orderBy = Integer.valueOf(parameter);
        }
        List<PriceRangeVo> priceRangeRank = billService.getPriceRangeRank(orderBy);
        ServletUtils.ok(resp,priceRangeRank);
    }
}
